package com.lims.algorithm.datastructure.generic;

public class GenericFruit {
	public static void main(String[] args) {
		Apple a = new Apple();
		Person p = new Person();
		
		GenericTest<Fruit> genericTest = new GenericTest<Fruit>();
		
		genericTest.show_1(a);
		//genericTest.show_1(p);
		
		genericTest.show_2(a);
		genericTest.show_2(p);
		
		genericTest.show_3(a);
		genericTest.show_3(p);
		
		printMsg("123","wer");
		
	}
	
	public static <T> void printMsg(T... args) {
		for (T t : args) {
			System.out.println("泛型可变参数测试：" + t);
		}
	}

}

class Fruit{
	@Override
	public String toString() {
		return "fruit";
	}
}
class Apple extends Fruit{
	@Override
	public String toString() {
		return "apple";
	}
}
class Person{
	@Override
	public String toString() {
		return "person";
	}
}

class GenericTest<T>{
	public void show_1(T t) {
		System.out.println(t.toString());
	}
	
	public <E> void show_2(E e) {
		System.out.println(e.toString());
	}
	
	public <T> void show_3(T t) {
		System.out.println(t.toString());
	}
}
